package com.baozun.houji.me.network

import com.baozhun.mall.common.model.bean.*
import com.baozhun.mall.common.network.NetworkApi
import com.baozun.houji.me.model.bean.SystemMsgBean
import com.baozun.houji.me.model.request.NotifyStatusReqBean
import com.baozun.houji.me.model.request.PhoneLoginReqBean
import retrofit2.http.*

/**
 * @Title：个人中心ApiService
 * @Description：
 * @Author：xuefeng.zhu
 * @Since：2022/11/4
 * @Version：1.0.0
 */
interface MeApiService {


    /**
     *
     * 获取收藏列表数据
     */
    @GET("user/get_favorite_list")
    suspend fun getCollectionList(
        @Query("page") page: Int,
        @Query("goods_type") goodsType: String
    ): ApiResponse<ApiPagerResponse<ArrayList<GoodsInfoBean>>>

    /**
     *
     * 获取浏览历史记录数据
     */
    @GET("user/get_browse_list")
    suspend fun getBrowseHistoryList(
        @Query("page") page: Int,
    ): ApiResponse<ApiPagerResponse<ArrayList<GoodsInfoBean>>>


    /**
     * 更新通知设置信息
     */
    @POST("user/user-notice")
    suspend fun updateNotifyStatus(@Body notifyStatusReqBean: NotifyStatusReqBean?): ApiResponse<Any?>

    /**
     * 退出登陆接口
     */
    @FormUrlEncoded
    @POST("customer/logout")
    suspend fun logout(@Field("id") id: String): ApiResponse<Any>



    /**
     * 获取系统消息
     */
    @GET("sys-msg/list")
    suspend fun getSystemMsgList(
        @Query("page") page: Int
    ): ApiResponse<ApiPagerResponse<List<SystemMsgBean>>>

    /**
     *
     * 获取用户地址列表
     */
    @GET("address/list")
    suspend fun getAddressList(): ApiResponse<MutableList<AddressInfo>>


    /**
     *
     * 保存地址
     */
    @POST("address/save")
    suspend fun saveAddress(@Body addressInfo: AddressInfo): ApiResponse<Any>

    /**
     *
     * 保存地址
     */
    @GET("address/delete")
    suspend fun deleteAddress(@Query("id") id: String): ApiResponse<Any?>

    /**
     * 获取省市区信息
     */
    @GET("address/region")
    suspend fun getAddressRegion(
    ): ApiResponse<MutableList<RegionBean>>

    /**
     * 获取热门城市
     */
    @GET("address/hot-region")
    suspend fun getHotAddressRegion(
    ): ApiResponse<MutableList<HotRegionBean>>

    /**
     * 注册
     */
    @POST("login/register")
    suspend fun register(
        @Body params: PhoneLoginReqBean?,
    ): ApiResponse<Any?>

    /**
     * 登录或注册
     */
    @FormUrlEncoded
    @POST("account/register-and-login")
    suspend fun login(
        @Field("phone") phone: String,
        @Field("verify_code") verifyCode: String,
    ): ApiResponse<UserInfo>

    /**
     * 检验验证码
     */
    @POST("login/validate-mail-code")
    suspend fun checkVerifyCode(
        @Body params: ResetPwdReqBean,
    ): ApiResponse<Any?>

    /**
     * 重置密码
     */
    @POST("login/reset-password")
    suspend fun resetPwd(
        @Body params: ResetPwdReqBean,
    ): ApiResponse<Any?>


}

/**
 * 双重校验锁式-单例 封装NetApiService 方便直接快速调用简单的接口
 */
val mMeApiService: MeApiService by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
    NetworkApi.INSTANCE.getApi(MeApiService::class.java, NetworkApi.Companion.SERVER_URL)
}